/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package facade;

import entities.Material;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author PabloSebastian
 */
@Stateless
@Remote (MaterialFacadeRemote.class)
public class MaterialFacade extends AbstractFacade<Material> implements MaterialFacadeRemote {
    @PersistenceContext(unitName = "Javeriana.EJB.EstimatorPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public MaterialFacade() {
        super(Material.class);
    }

    @Override
    public List<String> findAllMaterials() {
        List<Material> listMaterial = this.findAll();
        List<String> materiales = new ArrayList<>();
        for (Material material : listMaterial) {
            materiales.add(material.getTypematerial());
        }
        
        return materiales;
    }
    
}
